package com.hzeport.bgs22emduty.inbound.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzeport.bgs22emduty.config.login.LoginCompoentService;
import com.hzeport.bgs22emduty.config.login.UserInfoDetailVO;
import com.hzeport.bgs22emduty.config.systemLog.OperLog;
import com.hzeport.bgs22emduty.dto.files.ScreenDutyFileDTO;
import com.hzeport.bgs22emduty.dto.files.ScreenDutyFileRemoveDTO;
import com.hzeport.bgs22emduty.dto.files.ScreenDutyFileSaveDTO;
import com.hzeport.bgs22emduty.entity.ScreenDutyFile;
import com.hzeport.bgs22emduty.service.ScreenDutyFileService;
import com.hzeport.bgs22emduty.vo.ScreenStandard.ScreenStandSortVO;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * ${comments}
 *
 * @author code generator
 * @date 2023-02-14 09:39:44
 */
@RestController
@AllArgsConstructor
@RequestMapping("/screendutyfile")
@Api(value = "screendutyfile", tags = "文件库管理")
@Slf4j
public class ScreenDutyFileController {

    private final ScreenDutyFileService screenDutyFileService;

    private final LoginCompoentService loginCompoentService;

    @ApiOperation(value = "分页查询", notes = "分页查询")
    @PostMapping("/page")
    public BaseResult getScreenDutyFilePage(@RequestBody ScreenDutyFileDTO screenDutyFile) {
        Page<ScreenDutyFile>  dutyMessageList=screenDutyFileService.getScreenDutyFilePage(screenDutyFile);
        return BaseResult.ok(dutyMessageList);
    }


    /**
     **
     * 通过id查询${comments}
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("getById")
    public BaseResult getById(@RequestParam("id") String id) {
        return BaseResult.ok(screenDutyFileService.detail(id));
    }

    /**
     * 新增${comments}
     * @param screenDutyFile ${comments}
     * @return R
     */
    @ApiOperation(value = "新增${comments}", notes = "新增${comments}")
    //@SysLog(.*)
    @PostMapping("save")
    @OperLog(systemName = "WJK",description = "WJXZ")
    public BaseResult save(@Valid@RequestBody ScreenDutyFileSaveDTO screenDutyFileSaveDTO) {
        return BaseResult.ok(screenDutyFileService.saveFiles(screenDutyFileSaveDTO));
    }
//
//    /**
//     * 修改${comments}
//     * @param screenDutyFile ${comments}
//     * @return R
//     */
//    @ApiOperation(value = "修改${comments}", notes = "修改${comments}")
//    //@SysLog(.*)
//    @PostMapping("updateById")
//    public BaseResult updateById(@RequestBody ScreenDutyFile screenDutyFile) {
//        return BaseResult.ok(screenDutyFileService.updateById(screenDutyFile));
//    }

    /**
     * 通过id删除${comments}
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除${comments}", notes = "通过id删除${comments}")
    //@SysLog(.*)
    @PostMapping("/delete")
    @OperLog(systemName = "WJK",description = "WJSC")
    public BaseResult remove(@Valid @RequestBody ScreenDutyFileRemoveDTO screenDutyFileRemoveDTO) {
        return BaseResult.ok(screenDutyFileService.remove(screenDutyFileRemoveDTO));
    }

    @ApiOperation( value = "序号排序" )
    @RequestMapping( value = "saveSort", method = RequestMethod.POST )
    @OperLog(systemName = "WJK",description = "WJPX")
    public BaseResult updatesort( @RequestBody ScreenStandSortVO screenStandardSort ) {
        UserInfoDetailVO userInfoDetailVO = loginCompoentService.getUserInfo();
        return screenDutyFileService.saveSort( screenStandardSort , userInfoDetailVO );
    }

}
